#!/usr/bin/env node

const Koa = require('koa'),//需要Koa实例化对象，所以要大写
      log = console.log;

let app = new Koa();

app.use(async (c,next)=>{// M-logger
  log(`${c.method} ${c.path}`);
  let start = Date.now();
  await next();
  let end = Date.now();
  log(`${end - start} ms`);
});


app.use((c,next)=>{// M-hello
  log('hello koa');
  c.body = 'hello koa';
});


app.listen(8080);


